﻿// =================================================================== 
// Module说明
//====================================================================
// 创建时间：2018-05-15 10:35:52
// 负责人：Sushee
// ===================================================================
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq.Expressions;
using OF.Utility;
using OF.Component.Model;
using OF.Component.IDAL;
using OF.Component.Factory;
namespace OF.Component.BLL
{
	
	/// <summary>
	/// 扩展
	/// </summary>
	public partial class AuthorityRoleMenuRelaOperate
	{
        /// <summary>
    	/// 根据断言条件获取单个
    	/// </summary>
        public static AuthorityRoleMenuRelaInfo QuerySingle(Expression<Func<AuthorityRoleMenuRelaInfo, bool>> predicate)
        {
            return dal.QuerySingle(predicate);
        }
        /// <summary>
    	/// 根据断言条件获获取列表
    	/// </summary>
        public static IList<AuthorityRoleMenuRelaInfo> QueryList(Expression<Func<AuthorityRoleMenuRelaInfo, bool>> predicate)
        {
            return dal.QueryList(predicate);
        }
        ///<summary>
        ///修改ByID
        ///</summary>
        public static void DeleteRoleMenu(int RoleID, int SystemID)
        {
            dal.DeleteRoleMenu(RoleID, SystemID);
        }

        /// <summary>
        /// 根据角色获取菜单 
        /// </summary>
        /// <param name="RoleID">1超级管理员，拥有所有菜单权限 </param>
        /// <param name="SystemID"></param>
        public static IList<AuthorityMenuInfo> GetRoleMenuList(int RoleID, int SystemID)
        {
            if (RoleID == 1)
            {
                int outNum = 1;
                return AuthorityMenuOperate.Search(out outNum, 1, 1000, "isActive=1", "OrderNum", false);
            }
            return dal.GetRoleMenuList(RoleID, SystemID);
        }

        /// <summary>
        /// 根据系统ID和角色ID获取操作权限字符串
        /// </summary>
        /// <param name="RoleID">角色ID</param>
        /// <param name="SystemID">系统ID</param>
        /// <returns>菜单ID串</returns>
        public static string GetAuthorityToString(int RoleID, int SystemID)
        {
            string strAuth = ",";
            IList<AuthorityRoleMenuRelaInfo> list = null;
            list = dal.GetRoleMenuBySystemIDandRoleID(RoleID, SystemID);
            foreach (AuthorityRoleMenuRelaInfo info in list)
            {
                strAuth += info.MenuID.ToString() + ",";
            }
            return strAuth;
        }
    }
}